<!--
 * @Author: Freude Xu
 * @Date: 2021-09-17 14:19:37
 * @LastEditors: Freude Xu
 * @LastEditTime: 2021-09-23 16:24:05
 * @Description: 底部组件封装
-->
<template>
    <div>
        <!-- 底部 -->

        <div class="footer">
            <div class="wrapper">
                <div class="address">
                    <div class="address_first">
                        {{ school }}
                        <br />
                        {{ text }}
                        <br />
                        {{ address }}
                        <br />
                        {{last}}
                    </div>
                </div>
            </div>
        </div>
        <!-- /底部 -->
    </div>
</template>

<script>
    import {
        get
    } from "../utils/request";
    export default {
        data() {
            return {
                school: "",
                text: "",
                address: "",
                last:""
            };
        },
        created() {
            this.loadSchool();
            this.loadAddress();
            this.loadText();
            this.loadLast();
        },
        methods: {
            //加载校区名称
            loadSchool() {
                let url = "/index/findByKey";
                get(url, {
                    name: "school",
                }).then((res) => {
                    let data = res.data;
                    if (data) {
                        this.school = data.val;
                    }
                });
            },
            //加载邮编
            loadText() {
                let url = "/index/findByKey";
                get(url, {
                    name: "text",
                }).then((res) => {
                    let data = res.data;
                    if (data) {
                        this.text = data.val;
                    }
                });
            },
            //加载学校地址
            loadAddress() {
                let url = "/index/findByKey";
                get(url, {
                    name: "address",
                }).then((res) => {
                    let data = res.data;
                    //如果地址存在的话 则返回
                    if (data) {
                        this.address = data.val;
                    }
                });
            },
            //加载底部最后一项
            loadLast(){
                let url = "/index/findByKey";
                get(url, {
                    name: "last",
                }).then((res) => {
                    let data = res.data;
                    //如果地址存在的话 则返回
                    if (data) {
                        this.last = data.val;
                    }
                });
            }
        },
    };
</script>

<style lang="scss">
    //底部样式
    .footer {
        background-color: #8f000b;
        color: #d9eee1;
        height: 200px;

        &>.wrapper ::after {
            display: block;
            content: "";
            clear: both;
        }

        .address {
            padding: 3em 3em 0 3em;
            .address_first {
                text-align: center;
                line-height: 2em;
            }
        }
    }
</style>